/****************************************************************************
 * Copyright (C) 2009-2010 SciTouch LLC
 * 
 * This file is part of Indigo toolkit.
 * 
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 3 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 * 
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 ***************************************************************************/

#ifndef __molecule_arom_match_h__
#define __molecule_arom_match_h__

#include "base_cpp/array.h"
#include "molecule/molecule.h"
#include "molecule/molecule_dearom.h"
#include "molecule/molecule_arom.h"

class AromaticityMatcher
{
public:
   AromaticityMatcher (const Molecule &query, const Molecule &base);

   // Update internal structures when query molecule changes (grow)
   void validateQuery ();

   void fixAromaticBond              (int edge_idx);
   void fixAtom                      (int query_idx, int base_idx);
   void unfixNeighbourAromaticBonds  (int atom_idx);

   bool isAbleToFixBond              (int edge_idx);
   bool isAbleToMatch                ();

   void setQueryVertexIgnoreFilterPtr (int *query_vertices_filter, int ignore_value);
protected:
   const Molecule  &_query;
   const Molecule       &_base;

   bool  _needPrepare;

   TL_CP_DECL(Array<int>, _edgesMatching);
   TL_CP_DECL(Array<int>, _verticesFilter);
   TL_CP_DECL(Molecule,   _submolecule);

   int *_query_vertices_filter;
   int _ignore_value;
};

struct SubstructureMatchUserData
{
   SubstructureMatchUserData (const Molecule &query, const Molecule &base) : 
      aromaticityMatcher(query, base) {}

   AromaticityMatcher aromaticityMatcher;
};

#endif
